package com.link510.aitools.core.enums;

import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum XFVoice implements Serializable {

    xiaoyan("xiaoyan", "讯飞小燕", "普通话"),
    aisjiuxu("aisjiuxu", "讯飞许久", "普通话"),
    aisxping("aisxping", "讯飞小萍", "普通话"),
    aisjinger("aisjinger", "讯飞小婧", "普通话"),
    aisbabyxu("aisbabyxu", "讯飞许小宝", "普通话");

    /**
     * 代码
     */
    private String code = "";

    /**
     * 发音人
     */
    private String name = "";


    /**
     * 语种
     */
    private String language = "";


    public static XFVoice getVoiceCode(String code2) {

        try {

            for (XFVoice voice : values()) {

                if (voice == null) {
                    continue;
                }

                if (voice.getCode().equals(code2)) {
                    return voice;
                }

            }

            return xiaoyan;
//
//            return Arrays.stream(values()).filter(Objects::nonNull)
//                    .filter(x -> x.getCode().equals(code2)).findFirst().orElse(xiaoyan);

        } catch (Exception ignored) {

        }

        return xiaoyan;
    }
}
